package cn.doitedu.day04

import org.apache.spark.storage.StorageLevel
import org.apache.spark.{SparkConf, SparkContext}

object T09_CacheAndPersistDemo {

  def main(args: Array[String]): Unit = {

    //1.创建SparkConf
    val conf = new SparkConf().setAppName("WordCount")
      .setMaster("local[4]") //如果提交到集群中运行，setMaster必须注释掉

    //2.创建SparkContext
    val sc = new SparkContext(conf)

    val rdd1 = sc.textFile("hdfs://node-1.51doit.cn:8020/data/cache")

    //rdd1.cache()
    rdd1.persist(StorageLevel.MEMORY_ONLY_SER)

    rdd1.count()

  }

}
